package com.sfh.alliance.beauty;

import android.graphics.Bitmap;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sfh.alliance.R;
import com.sfh.entity.Beauty;
import com.sfh.entity.BeautyJson;
import com.squareup.picasso.Picasso;

import java.io.File;

/**
 * 功能描述:
 *
 * @date 2017/9/4
 */
public class BeautyAdapter extends BaseQuickAdapter<Beauty, BaseViewHolder> {

    public BeautyAdapter() {

        super (R.layout.beauty_adapter);
    }

    @Override
    protected void convert(BaseViewHolder helper, Beauty item) {

        helper.setText (R.id.tv_love, String.valueOf (item.getIntimacy ()));
        helper.setText (R.id.tv_flower, String.valueOf (item.getBeauty ().getCharm ()));
        ImageView iv_name = helper.getView (R.id.iv_name);
        ImageView iv_head = helper.getView (R.id.iv_head);
        ImageView iv_bg = helper.getView (R.id.iv_bg);

        BeautyJson json = item.getBeauty ();
        Picasso.with (this.mContext)
                .load (new File ("android_asset/"+json.getName ())).config (Bitmap.Config.RGB_565)
                .into (iv_name);

        Picasso.with (this.mContext)
                .load (new File ("android_asset/"+json.getHead ())).config (Bitmap.Config.RGB_565)
                .resize (200,200)
                .centerCrop ()
                .into (iv_head);

        Picasso.with (this.mContext)
                .load (new File ("android_asset/"+json.getWife ())).config (Bitmap.Config.RGB_565)
                .into (iv_bg);
    }
}
